//
//  GYInvoiceTypeTableViewCell.m
//  GoodLuck
//
//  Created by apple on 2018/4/2.
//  Copyright © 2018年 yunjiazhineng. All rights reserved.
//

static NSString *invoiceTypeCellIdentifier = @"invoiceTypeCellIdentifier";

#import "GYInvoiceTypeTableViewCell.h"

@interface GYInvoiceTypeTableViewCell ()
@property (weak, nonatomic) IBOutlet UIButton *personBtu;
@property (weak, nonatomic) IBOutlet UIButton *companyBtu;

@end
@implementation GYInvoiceTypeTableViewCell

+ (instancetype)cellWithTableView:(UITableView *)tableView {
    GYInvoiceTypeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:invoiceTypeCellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] firstObject];
    }
    
    return cell;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    //设置按钮的属性
    self.personBtu.layer.cornerRadius = 4;
    self.personBtu.layer.borderColor = RGBColor(221, 221, 221).CGColor;
    
    self.companyBtu.layer.cornerRadius = 4;
    self.companyBtu.layer.borderWidth = 2;
    self.companyBtu.layer.borderColor = RGBColor(221, 221, 221).CGColor;

    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (IBAction)onClick:(UIButton *)sender {
    self.selectInvoiceTypeCallBack(sender.tag);
}

- (void)setInvoiceType:(BOOL)invoiceType {
    _invoiceType = invoiceType;
    
    if (invoiceType) {
        self.personBtu.layer.borderWidth = 0;
        [self.personBtu setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.personBtu setBackgroundColor:RGBColor(15, 206, 194)];
        
        self.companyBtu.layer.borderWidth = 2;
        [self.companyBtu setTitleColor:RGBColor(125, 125, 125) forState:UIControlStateNormal];
        [self.companyBtu setBackgroundColor:[UIColor whiteColor]];

    }else {
        self.personBtu.layer.borderWidth = 2;
        [self.personBtu setTitleColor:RGBColor(125, 125, 125) forState:UIControlStateNormal];
        [self.personBtu setBackgroundColor:[UIColor whiteColor]];
        
        self.companyBtu.layer.borderWidth = 0;
        [self.companyBtu setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.companyBtu setBackgroundColor:RGBColor(15, 206, 194)];
    }
}

@end
